package com.woniuxy.merchant.controller;


import com.woniu.dto.CompanyDto;
import com.woniu.form.UpdateCompanyForm;
import com.woniu.zsd.commons.core.model.Result;
import com.woniuxy.merchant.service.ICompanyService;
import com.woniu.commons.util.TokenUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 公司详情表 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-05-13
 */
@RestController
@Api(tags = "公司详情")
@RequestMapping("/company")
public class CompanyController {
    @Resource
    private ICompanyService companyService;
    @Autowired
    private TokenUtil tokenUtil;
    @ApiOperation(value = "查询公司信息")
    @GetMapping("/list")
    public Result<CompanyDto> adminFindCompany() {
        CompanyDto companyContactDto = companyService.adminFindCompany();
        return new Result<CompanyDto>().setCode(200).setMsg("管理员查询公司信息成功").setData(companyContactDto);
    }
    @ApiOperation(value = "公司信息修改")
    @PutMapping("/update")
    public Result updateCompany(@RequestBody UpdateCompanyForm updateCompanyForm,
                                @RequestHeader @ApiParam(value = "管理员ID") String token){
        Integer adminId = tokenUtil.getAdminId(token);
        companyService.updateCompany(updateCompanyForm);
        return Result.getResult().setCode(200).setMsg("修改公司信息成功");
    }


}
